package com.bear.sgg.springboot_08_jdbc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Array;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @ClassNmae JdbcController
 * @Description TODO
 * @Author bear
 * @Date 2020/3/14 0014 下午 12:37
 */
@Controller
public class JdbcController {

    //spring boot中可以利用jdbcTemplate来实现sql操作，比jdbc原生的接口更方便
    @Autowired
    JdbcTemplate jdbcTemplate;

    @RequestMapping("/getData")
    @ResponseBody
    public List getData() {
        List<Map<String, Object>> data = jdbcTemplate.queryForList("select * from airplane");
        System.out.println(data.toString());
        return data;
    }
}
